import java.sql.*;
public class MysqlDemo {
    static final String USER="root";
    static final String PASS="a19901017";
    static final String DB_URL="jdbc:mysql://localhost:3306/yiibaidb";

    public static void main(String[] args)  {
        Connection conn=null;
        Statement sta=null;
        try{
            Class.forName("com.mysql.jdbc.Driver");
            System.out.println("Connecting to database....");
            conn=DriverManager.getConnection(DB_URL,USER,PASS);
            System.out.println("creating statement....");
            sta=conn.createStatement();
            String sql;
            sql="SELECT firstName FROM Employees";
            ResultSet rs=sta.executeQuery(sql);
            while (rs.next()){
                String firstName =rs.getString("firstName");
                System.out.println("firstName"+firstName);

            }
            rs.close();
            sta.close();
            conn.close();
        }
            catch (SQLException e){e.printStackTrace();
        }catch(ClassNotFoundException e){
            e.printStackTrace();
        }





    }
}
